<?php echo CHtml::link(Yii::t('main','add'), Yii::app()->createUrl('admin/settings/createDropDownSetting'),array(
    'onClick'=>'Setting.createDropDownSetting($("#setting-dropdown-new")); return false;',
    'class'=>'submit-green left',
)); ?>

<?php $dropDowns=$model->dropDownModels; ?>

<div id="setting-fom-dropdown-fields">

    <?php if($dropDowns): ?>
        <?php
            $dropDownArray=$model->dropDownArray;
            $fieldId=$dropDowns[0]->id;
            $inputValue=isset($dropDownArray[$dropDowns[0]->name]) ? $dropDownArray[$dropDowns[0]->name] : '';
            unset($dropDowns[0]);
        ?>

        <div id="setting-dropdown-new" class="dropdown">
            <?php Yii::app()->controller->renderPartial('__settingDropDownChangeField',array(
                'model'=>$model,
                'form'=>$form,
                'inputValue'=>$inputValue,
                'fieldId'=>$fieldId,
            )) ?>
        </div>

        <?php if($dropDowns): ?>

            <?php foreach($dropDowns as $dropDown): ?>
                <div  class="dropdown">
                    <?php
                        $model->settingValue=$dropDown->name;
                        $fieldId=$dropDown->id;
                    ?>
                    <?php Yii::app()->controller->renderPartial('__settingDropDownChangeField',array(
                        'model'=>$model,
                        'form'=>$form,
                        'inputValue'=>isset($dropDownArray[$dropDown->name]) ? $dropDownArray[$dropDown->name] : $dropDown->name,
                        'fieldId'=>$fieldId,
                    )) ?>
                </div>
            <?php endforeach; ?>

        <?php endif; ?>

    <?php else: ?>

        <div id="setting-dropdown-new" class="dropdown<?php if(!$model->id){ echo ' hidden'; } ?>">
            <?php Yii::app()->controller->renderPartial('__settingDropDownChangeField',array(
                'model'=>$model,
                'form'=>$form,
            )) ?>
        </div>

    <?php endif; ?>

</div>
